import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import legacy from '@vitejs/plugin-legacy'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue({
    isProduction:true,
    // isProduction:false,
  }),],

  esbuild:{
    target: 'es2015', // 确保转译到ES2015以支持iOS 9
    //drop:['console','debugger'],
  },
  mode:"production",
  // mode:"development",
  build: {
    target: 'es2015', // iOS 9 Safari 支持 ES2015
    minify: 'esbuild',
    sourcemap:true,
    external:["vue","element-plus","axios","@element-plus/icons-vue"],
    cssCodeSplit:false,
    lib: {
      entry: "./lib/main.js",
      name: "LucasMyForm",
      fileName: (format)=>`lucas-form.${format}.js`
    },
    rollupOptions:{
      external:["vue","element-plus","axios","@element-plus/icons-vue"],
      output: {
        // 在 UMD 构建模式下为这些外部化的依赖提供一个全局变量
        globals: {
          "vue":"Vue",
          "element-plus":"ElementPlus",
          "axios":"axios",
          "@element-plus/icons-vue":"ElementPlusIconsVue"
        }
      },
    }
  }
})
